package top.mczhengyi.xyblog.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.mczhengyi.xyblog.entity.Reply;
import top.mczhengyi.xyblog.mapper.ReplyMapper;
import top.mczhengyi.xyblog.service.ReplyService;

import java.util.List;

@Service
public class ReplyServiceImpl implements ReplyService {
    @Autowired
    private ReplyMapper replyMapper;

    @Override
    public List<Reply> getRepliesByArticleId(int id) {
        return replyMapper.getReplyByTargetId(id);
    }

    @Override
    public List<Reply> getAllReply() {
        return replyMapper.getAllReply();
    }

    @Override
    public Integer saveReply(Reply reply) {
        reply.setVisible(false);
        return replyMapper.insert(reply);
    }

    @Override
    public Integer applyReply(int id) {
        return replyMapper.applyComment(id);
    }

    @Override
    public int deleteReply(int id) {
        return replyMapper.deleteById(id);
    }

}
